package com.pll.controller.admin.commodity;

import com.pll.controller.admin.commodity.vo.CommodityPaginationVO;
import com.pll.controller.admin.commodity.vo.ProductInformationVO;
import com.pll.dto.ResponseDto;
import com.pll.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: CommodityController
 * @author: XR_Z
 * @date: 2025/6/7 18:22
 * @Version: 1.0
 * @description: 商品
 */

@RestController
@RequestMapping("/commodity")
public class CommodityController {

    @Autowired
    private CommodityService commodityService;

    /**
     * 获取全部商品
     * @return dto
     */
    @GetMapping("/getItAll")
    public ResponseDto getItAll(){
        return commodityService.getItAll();
    }

    /**
     * 多条件分页复合获取商品信息
     * @param commodityPaginationVO 分页信息
     * @return dto
     */
    @PostMapping("/getItByPagination")
    public ResponseDto getItByPagination(@RequestBody CommodityPaginationVO commodityPaginationVO){
        return commodityService.queryGoods(commodityPaginationVO);
    }

    //新增商品（商品上传）
    @PostMapping("/addANewProduct")
    public ResponseDto addANewProduct (){

        return null;
    }
    //修改商品
    @PostMapping("/modifyTheProduct")
    public ResponseDto modifyTheProduct(@RequestBody ProductInformationVO productInformationVO){

        return commodityService.modifyTheProduct(productInformationVO);
    }
    //删除商品
    @PostMapping("/deleteTheItem")
    public ResponseDto deleteTheItem(@RequestParam int id){
        return commodityService.deleteTheItem(id);
    }

    //批量删除
    @PostMapping("/deleteInBulk")
    public ResponseDto deleteInBulk(@RequestBody List<Integer> ids){
        return commodityService.deleteInBulk(ids);
    }
}
